package com.ruoyi.common.core.redis;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

/**
 * redis 监听器实现回调功能
 * 开启Redis的过期回调功能
 * 1.修改redis.conf文件
 * 2.开启notify-keyspace-events Ex的配置
 * 3.重启redis服务
 * @Author Alan Zhang
 * @Date 2025/4/1 16:14
 */
@Configuration
public class RedisListenerConfig {
    @Bean
    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {

        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        return container;
    }
}
